#ifndef SKYROAD__WCHARFUNCTION_H__
#define SKYROAD__WCHARFUNCTION_H__

#ifndef _WIN32
	#ifndef ANDROID
		#include <iconv.h>
	#endif
	#include <errno.h>
#endif


#include "basetype.h"
#include <string.h>
#include <wchar.h>
#include <ctype.h>



#ifndef _WIN32

extern int  StringConvert( char* szFromCharset,char* szToCharset,char *szIn,int nInLen,char* szOut,int nOutLen );

extern char* _strupr( char *string);
extern char* _strlwr( char *string);
extern WCHAR* _wcsupr( WCHAR *string);
extern WCHAR* _wcslwr( WCHAR *string);

#define strupr		_strupr
#define strlwr		_strlwr

#define wcsupr		_wcsupr
#define wcslwr		_wcslwr

#define _strnicmp	strncasecmp
#define _stricmp	strcasecmp

#define _snwprintf	swprintf

#ifdef ANDROID
#define wcsicmp		wcscmp
#define stricmp		strcasecmp
#else
#define wcsicmp		wcscasecmp
#endif

extern int		StringFromGUID2( REFGUID rguid,WCHAR *wszGuid,int ccMax );
extern HRESULT	GUIDFromString( WCHAR *wszGuid,GUID* lpGuid );

#define CLSIDFromString 	GUIDFromString
#define StringFromCLSID2	StringFromGUID2

#else

#ifdef _WIN32_WCE

#define stricmp		_stricmp
#define strdup		_strdup
#define strupr		_strupr

#endif

#endif


#include <skyroad/detail/config.hpp>

// class SKYROAD_DECL char_function
// {
// public
extern    HRESULT	GUIDFromString( const CHAR *szGuid,GUID* lpGuid );

extern    char*  strreplace( char* string,char srch,char tgch );
extern    WCHAR* wcsreplace( WCHAR* string,WCHAR srch,WCHAR tgch );

extern    int ConvertUtf8ToUnicode(const CHAR * szIn,WCHAR *wszOut,int nSize );

extern    int ConvertUnicodeToUtf8(const WCHAR * wszIn,CHAR *szOut,int nSize );

extern    int ConvertUtf8ToAnsi(const CHAR * szIn,CHAR *szOut,int nSize );

extern    int ConvertAnsiToUtf8(const CHAR * szIn,CHAR *szOut,int nSize );

extern    int ConvertAnsiToUnicode(const CHAR * szIn,WCHAR *wszOut,int nSize );

extern    int ConvertUnicodeToAnsi(const WCHAR * wszIn,CHAR *szOut,int nSize );

extern    int ConvertAnsiToUnicode16(const CHAR * szIn,CHARU16 *szOut,int nSize );

extern    int ConvertUnicode16ToAnsi(const CHARU16 * szIn,CHAR *szOut,int nSize );

extern    int ConvertUtf8ToUnicode16(const CHAR * szIn,CHARU16 *szOut,int nSize );

extern    int ConvertUnicode16ToUtf8(const CHARU16 * szIn,CHAR *szOut,int nSize );

    #ifdef _WIN32

extern    void OutPutDebugStringEx(const TCHAR * format, ...);

    #else
    extern int ConvertUnicodeToUnicode16(const WCHAR * wszIn,CHARU16 *szOut,int nSize );

    extern  int ConvertUnicode16ToUnicode(const CHARU16 * szIn,WCHAR *wszOut,int nSize );
    #endif

#endif
